import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Login from "../views/Login.vue";
import Welcome from "../views/Welcome.vue";
import User from "../views/safty/User.vue";
import Role from "../views/safty/Role.vue";
import Password from "../views/safty/Password.vue";


//路由有bug，需要重写push方法
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error);
}

Vue.use(VueRouter);
const routes = [
  {
    path: "/",
    name: "Login",
    component: Login
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    children: [
      {
        path: '',
        name: 'Welcome',
        component: Welcome,
      },
      {
        path: 'safty/user',
        name: 'User',
        component: User,
      },
      {
        path: 'safty/role',
        name: 'Role',
        component: Role,
      },
      {
        path: 'safty/password',
        name: 'password',
        component: Password,
      },
      
    ],
  },
];

const router = new VueRouter({
  routes
});

export default router;
